package Mangos::DB::Characters::Guild;

use strict;
use warnings;

use Data::Dumper;
use base qw(Mangos::DB::Characters);
use Mangos::DB::Characters::GuildMember;

__PACKAGE__->meta->setup
(
    table   => 'guild',

    columns => 
    [
        guildid         => { type => 'integer', not_null => 1 },
        name            => { type => 'varchar', default => '', length => 255, not_null => 1 },
        leaderguid      => { type => 'integer', default => '0', not_null => 1 },
        EmblemStyle     => { type => 'integer', default => '0', not_null => 1 },
        EmblemColor     => { type => 'integer', default => '0', not_null => 1 },
        BorderStyle     => { type => 'integer', default => '0', not_null => 1 },
        BorderColor     => { type => 'integer', default => '0', not_null => 1 },
        BackgroundColor => { type => 'integer', default => '0', not_null => 1 },
        info            => { type => 'text', length => 65535, not_null => 1 },
        motd            => { type => 'varchar', default => '', length => 255, not_null => 1 },
        createdate      => { type => 'bigint', default => '0', not_null => 1 },
        BankMoney       => { type => 'bigint', default => '0', not_null => 1 },
    ],

    primary_key_columns => [ 'guildid' ],
);

sub members {
   my ($self, $db, $guildid) = @_;
   my @members;

   $guildid = $self->guildid unless ($guildid);

   @members = Mangos::DB::Characters::GuildMember::Manager->get_guild_member( db => $db, with_objects => 'Characters', query => [ guildid => $guildid ] );
 
   return \@members;
}

1;

package Mangos::DB::Characters::Guild::Manager;

use strict;
use warnings;

use base 'Rose::DB::Object::Manager';

sub object_class { 'Mangos::DB::Characters::Guild' }

__PACKAGE__->make_manager_methods('guild');

1;
